import { http } from '@/utils/http';
import type { LoginResult } from '@/types/auth';
import type { AnyObj } from '@/types/global';
import { useAuthStore } from '@/stores';
import { isLogin, getWxUserId, getWxOpenId, getLawFirmId } from '@/utils/auth';
const appId = import.meta.env.VITE_APP_ID;
const clientId = import.meta.env.VITE_CLIENT_ID;
const grantType = 'miniapp';


export const getTradeListAssignOrder = (data : AnyObj) => {
	const lawFirmId = getLawFirmId();
	return http<AnyObj>({
		method: 'GET',
		url: `/wx/trade/listAssignOrder`,
		data: {
			...data,
			lawFirmId
		}
	});
}

export const takeOrder = (trackingNumber : string) => {
	const wxUserId = getWxUserId();
	const lawFirmId = getLawFirmId();
	return http<AnyObj>({
		method: 'POST',
		url: `/wx/trade/takeOrder`,
		data: {
			trackingNumber,
			wxUserId,
			lawFirmId,
		}
	});
}

export const getOrderDetail = (orderId : string) => {
	return http<AnyObj>({
		method: 'GET',
		url: `/wx/trade/${orderId}`,
	});
}

export const completedOrder = (trackingNumber : string) => {
	return http({
		method: 'POST',
		url: `/wx/trade/takeCompletedOrder`,
		data: {
			trackingNumber
		}
	});
}

export const getOrderStat = () => {
	const wxUserId = getWxUserId();
	return http<AnyObj>({
		method: 'GET',
		url: `/wx/trade/orderStat/${wxUserId}`,
	});
}


export const getAssignDetail = (trackingNumber : string) => {
	return http<AnyObj>({
		method: 'GET',
		url: `/wx/trade/assignOrder/${trackingNumber}`,
	});
}